#!/bin/bash


# See http://code.google.com/p/wispinabox/issues/detail?id=8
echo "LAME MYSQL REMOVAL"
echo "See: http://code.google.com/p/wispinabox/issues/detail?id=8"
#if [ -f /etc/init.d/mysql ] ; then /etc/init.d/mysql stop ; fi
#killall -9 mysqld_safe
echo "mysql-server-5.0 mysql-server-5.0/postrm_remove_databases select true" | debconf-set-selections
apt-get --yes  purge mysql-server-5.0 


# clean up any junk
dpkg --configure -a


# - create a minimal base to work from ---------------------------------------
echo "Removing packages"

# bluetooth support
apt-get --yes  purge bluez-audio bluez-cups bluez-gnome bluez-utils

# open office
apt-get --yes  purge openoffice.org-base-core openoffice.org-calc             \
                 openoffice.org-common openoffice.org-core                \
                 openoffice.org-draw openoffice.org-gnome                 \
                 openoffice.org-gtk openoffice.org-help-en-gb             \
                 openoffice.org-help-en-us openoffice.org-hyphenation     \
                 openoffice.org-hyphenation-en-us openoffice.org-impress  \
                 openoffice.org-l10n-common openoffice.org-l10n-en-gb     \
                 openoffice.org-l10n-en-za openoffice.org-style-human     \
                 openoffice.org-writer openoffice.org-thesaurus-en-au     \
                 openoffice.org-thesaurus-en-us 

# multimedia
apt-get --yes  purge rhythmbox soundjuicer totem totem-common totem-gstreamer \
                 totem-mozilla totem-plugins

# bittorrent
apt-get --yes  purge transmission-common transmission-gtk

# evolution 
#apt-get --yes  purge evolution evolution-common evolution-exchange \
#                 evolution-plugins evolution-webcal    
# ubuntu-desktop wants evolution-data-server-common 
# ekiga          wants evolution-data-server

# ekiga
# apt-get --yes  purge ekiga evolution-data-server 

# don't sue me! get rid of mono & mono apps
apt-get --yes  purge f-spot tomboy
apt-get --yes  purge mono-common mono-gac mono-jit mono-runtime libmono0 \
                 libmono1.0-cil libmono2.0-cil

# eye candy
apt-get --yes  purge compiz compiz-core compiz-fusion-plugins-extra \
                 compiz-fusion-plugins-main compiz-gnome compiz-plugins \
                 compizconfig-backend-gconf libcompizconfig0

# gimp
apt-get --yes  purge gimp gimp-data gimp-help-common gimp-help-en gimp-python gimp-gnomevfs 

#  games
apt-get --yes  purge gnome-games gnome-games-data  

# languages
apt-get --yes  purge language-pack-de language-pack-de-base language-pack-gnome-de language-pack-gnome-de-base \
                 language-pack-es language-pack-es-base language-pack-gnome-es language-pack-gnome-es-base \
                 language-pack-fr language-pack-fr-base language-pack-gnome-fr language-pack-gnome-fr-base \
                 language-pack-pt language-pack-pt-base language-pack-gnome-pt language-pack-gnome-pt-base 

# fonts
apt-get --yes  purge ttf-arabeyes ttf-arphic-uming ttf-indic-fonts-core \
                 ttf-kochi-gothic ttf-kochi-mincho ttf-lao          \
                 ttf-malayalam-fonts ttf-thai-tlwg                           


# - wispinabox dependencies --------------------------------------------------
apt-get --yes  purge freeradius freeradius-mysql

echo "mysql-server-5.0 mysql-server-5.0/postrm_remove_databases select true" | debconf-set-selections
apt-get --yes  purge mysql-server-5.0 

apt-get --yes purge libdbd-mysql-perl libdbi-perl libmysqlclient15off \
                 libnet-daemon-perl libplrpc-perl mysql-client-5.0 mysql-common 

apt-get --yes purge apache2 apache2-mpm-worker apache2-utils apache2.2-common \
                    libapr1 libaprutil1 libpq5

apt-get --yes purge php5 apache2-mpm-prefork libapache2-mod-php5 php5-common


# - wispinabox configurations ------------------------------------------------
apt-get --yes purge wispinabox-freeradius
apt-get --yes purge wispinabox-dashboard


# - dangly bits --------------------------------------------------------------
apt-get --yes  autoremove



# - diagnostics --------------------------------------------------------------
#dpkg --get-selections > /tmp/installed-packages
#dpkg --get-selections | sed s/"\tinstall"// | sed s/"deinstall"// > /tmp/installed-packages.seed
dpkg --get-selections | grep "deinstall" | sed s/"deinstall"// > /tmp/installed-packages.removed
dpkg --get-selections | grep -v "deinstall" | sed s/"\tinstall"// > /tmp/installed-packages.installed

